<template>
  <view class="container">
    <view class="tool-grid">
      <view 
        v-for="tool in tools"
        :key="tool.name"
        class="tool-item"
        @click="navigateTo(tool)"
      >
        <img :src="tool.icon" class="tool-icon" alt="">
        <view class="tool-name">{{ tool.name }}</view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      tools: [
        { name: 'BMI计算', icon: require('@/static/images/indexImg/bmi.png'), url: '/subpage/articleInfo/articleInfo?toolType=BMI计算' },
        { name: '血型预测', icon: require('@/static/images/indexImg/blood.png'), url: '/subpage/articleInfo/articleInfo?toolType=血型预测' },
        { name: '驾考成绩模拟', icon: require('@/static/images/indexImg/jiazhao.png'), url: '/subpage/jiakaoInfo/jiakaoIndex' },
        { name: '轮盘抽奖', icon: require('@/static/images/indexImg/choujiang.png'), url: '/subpage/lottery/index' },
        { name: '自定义二维码', icon: require('@/static/images/indexImg/erweima.png'), url: '/subpage/qrcode/index' },
        { name: '识别WIFI密码', icon: require('@/static/images/indexImg/saoma.png'), url: '/subpage/scancode/index' },
        { name: '人生调色板', icon: require('@/static/images/indexImg/colorband.png'), url: '/subpage/colorBand/index' },
        // { name: '开发中…', icon: require('@/static/images/indexImg/coding.png'), url: '/subpage/colorBand/index' }
      ]
    };
  },
  methods: {
    navigateTo(tool) {
      uni.navigateTo({ url: tool.url });
    }
  }
};
</script>

<style lang="scss" scoped>
.container {
  padding: 30rpx;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200rpx, 1fr));
  gap: 24rpx;
  width: 100%;
  max-width: 750rpx;
}

.tool-item {
  box-shadow: rgba(50, 50, 93, 0.25) 0px 6rpx 6rpx -2rpx, rgba(0, 0, 0, 0.3) 0px 3px 7px -3px;
  border-radius: 15rpx;
  background-color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20rpx;
  transition: transform 0.2s;

  &:hover {
    transform: scale(1.05);
  }

  .tool-icon {
    width: 100rpx;
    height: 100rpx;
    object-fit: cover;
    border-radius: 50%;
    margin-bottom: 10rpx;
  }

  .tool-name {
    font-size: 28rpx;
    color: #333;
    font-weight: 500;
  }
}
</style>